﻿@using mscook.mvc;
<input type="hidden" id="perValue" value="@ViewData[ViewDataKeys.PERVALUE]" />
<div class="row-fluid">
    <div class="span12">
        <div class="controls">
            每页显示
                        <select id="selectper" style="width: 80px;" data-rel="chosen" class="chzn-done">
                            <option>10</option>
                            <option>15</option>
                            <option>20</option>
                            <option>25</option>
                            <option>30</option>

                        </select>
            条，共 @ViewData[ViewDataKeys.TOTAL_AMOUNT]条
        </div>
    </div>
</div>
<div class="span12 center">
    <div class="dataTables_paginate paging_bootstrap pagination" id="pageBreak">
        <ul>
            @if (!ViewData[ViewDataKeys.CURRENT_PAGE].ToString().Equals("1"))
            {
                var prePage = Int32.Parse(ViewData[ViewDataKeys.CURRENT_PAGE].ToString()) - 1;
                // var href = ViewData[ViewDataKeys.HRRF].ToString() + prePage;
                <li class="prev"><a data-num="@prePage" href="#">← 上一页</a></li>
            }
            else
            {
                <li class="prev disabled"><a href='#'>← 上一页</a></li>
            }

            <!--显示“页数”的样式-->
            @for (var i = 0; i < ViewBag.PageList.Length; i++)
            {
                var item = ViewBag.PageList[i];
                if (!item.ToString().Equals("0"))
                {
                    if (ViewData[ViewDataKeys.CURRENT_PAGE].ToString().Equals(item.ToString()))
                    {
                <li class="active"><a href="#">@item</a></li>
                    }
                    else
                    {
                        // var href = ViewData[ViewDataKeys.HRRF].ToString() + item;
                <li><a href="#" data-num="@item">@item</a></li>
                    }
                }
            }

            <!--显示“下一页”的样式-->
            @if (!ViewData[ViewDataKeys.TOTAL_PAGE].ToString().Equals("0") && !ViewData[ViewDataKeys.CURRENT_PAGE].ToString().Equals(ViewData[ViewDataKeys.TOTAL_PAGE].ToString()))
            {
                var nextPage = Int32.Parse(ViewData[ViewDataKeys.CURRENT_PAGE].ToString()) + 1;
                //  var href = ViewData[ViewDataKeys.HRRF].ToString() + nextPage;
                <li class="prev"><a href="#" data-num="@nextPage">下一页 →</a></li>
                   
            }
            else
            {
                <li class="next disabled"><a href="#">下一页 →</a></li>
            }
        </ul>
    </div>
</div>

<script type="text/javascript">
    jQuery(document).ready(function ($) {
        (function () {
            var per = $("#perValue").val();
            $("#selectper").val(per);
        })();

        $("#pageBreak li a").bind("click", function () {
            var pageNum = $(this).data("num");
            if (pageNum != undefined && pageNum != "") {
                $("#nowPageNum").val(pageNum);
                $("#searchForm").submit();
            }
            //var perValue = $("#selectper").val();
            //openPage(pageNum, perValue);
            return false;


        });


        $("#selectper").change(function () {
            $("nowPageNum").val("1");
            $("#per").val($(this).val());
            $("#searchForm").submit();
            //openPage(1, $(this).val());
        });
      

    });
</script>
